614B - Gena's Code - CodeForces Solution


implementation math *1400

Please click on ads to support us..

Python Code:

t = int(input())
n = list(map(int,input().split()))
res = 1
for i in range(t):
  if n[i]==0:
    res = 0
    break
  res*=n[i]
print(res)

C++ Code:

#include <iostream>
#include <bits/stdc++.h>
#define WINNABLE ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PRINTVP(vp) for(auto &i:vp)cout<<i.first<<" "<<i.second<<endl;
#define PRINTV(v) for(auto &i:v)cout<<i<<" ";
#define endl '\n'
typedef long long ll;
using namespace std;

bool notBeautiful(string s) {
    int ones = 0;
    for(char c : s) {
        if((c - '0') > 1)
            return true;
        if((c - '0') == 1)
            ones++;
    }
    if(ones > 1)
        return true;
    return false;
}

int main()
{
    int n; cin >> n;
    string s, zeros, nbtfl = "1";
    if(n == 1) {
        cin >> s;
        return cout << s, 0;
    }
    for(int i = 0; i < n; i++) {
        cin >> s;
        if(s == "0")
            return cout << 0, 0;
        if(notBeautiful(s)) {
            nbtfl = s;
        }
        else {
            for(char c : s) {
                if((c - '0') == 0)
                    zeros += '0';
            }
        }
    }
    cout << nbtfl << zeros;
}


Comments

Submit
0 Comments
More Questions

174. Dungeon Game
127. Word Ladder
123. Best Time to Buy and Sell Stock III
85. Maximal Rectangle
84. Largest Rectangle in Histogram
60. Permutation Sequence
42. Trapping Rain Water
32. Longest Valid Parentheses
Cutting a material
Bubble Sort
Number of triangles
AND path in a binary tree
Factorial equations
Removal of vertices
Happy segments
Cyclic shifts
Zoos
Build a graph
Almost correct bracket sequence
Count of integers
Differences of the permutations
Doctor's Secret
Back to School
I am Easy
Teddy and Tweety
Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes